<?php

class Admin_Form_MarkForm extends Zend_Form
{

    public function init()
    {
    	$this->setAttrib('class', 'validate-form');
    	
    	$this->addElement('text','txtHoDem',array(
    						'label'		=>	'Họ đệm',
    						'class'		=>	'required',
    						'required'	=>	TRUE	
    					)
    			);
    	$this->addElement('text','txtName',array(
    						'label'		=>	'Tên',
    						'class'		=>	'required',
    						'required'	=>	true
    					)
    			);
    	$this->addElement('select','cbbLop',array(
    						'label'			=>	'Lớp',
    						'class'			=>	'required',
    						'multiOptions'	=>	$this->getLop()
    					)
    			);
    	$this->addElement('select','cbbMon',array(
    						'label'			=>	'Môn học',
    						'class'			=>	'required',
    						'multiOptions'	=>	$this->getMon()
    					)
    			);
        $this->addElement('text','txtMarkHeSo1',array(
        					'label'		=>	'Điểm hệ số 1',
        					'class'		=>	'number',
        					'maxlength'	=>	4
		        		)
		        );
		$this->addElement('text','txtMarkHeSo2',array(
        					'label'		=>	'Điểm hệ số 2',
        					'class'		=>	'number',
        					'maxlength'	=>	4
		        		)
		        );
		$this->addElement('text','txtMarkThi',array(
        					'label'		=>	'Điểm thi',
        					'class'		=>	'number',
							'maxlength'	=>	4		
		        		)
		        );
		$this->addElement('select','cbbHocKy',array(
        					'label'		=>	'Học kỳ',
        					'class'		=>	'number',
							'multiOptions' => array(
										'1'	=>	'Học kỳ I',
										'2'	=>	'Học kỳ II'
							)
									
		        		)
		        );
		 $this->addElement('text','txtNamHoc',array(
		 					'label'		=>	'Năm học',
		 						
				 		)
				 );
		              
		
    }
    
     /**
     * 
     * Set action cho form
     * @param unknown_type $actionName: ten cua action
     */
    function addAction($actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/admin/mark/".$actionName);
    }
    
    /**
     * 
     * Add nut submit 
     */
    function addSubmitButton($name, $label){
    	$this->addElement('submit',$name,array(
    						'label'		=>	$label,
    						'decorators'=>	array('ViewHelper',array('HtmlTag',array(
    																			'tag' => 'dd' //giu nguyen the dd ko them bat cu the j
    																		)
    														
    															)
    							
    										),
    						'class'		=>	'input-hover uSubmit'	
    					));
    	
    }
    
    function addHiddenId($name,$value){
    	$this->addElement('hidden',$name,array(
			    				'value'	=> $value	
    						));
    }
    

	private function getMon(){
    	$mon = new Admin_Model_Monhoc();
    	$monHoc = $mon->fetchAllMonHoc();
    	$arrData = array();
    	foreach ($monHoc as $value) {
    		$arrData[$value['id']] =$value['tenMonHoc']	;
    	}
    	return $arrData;
    }
    
    private function getLop(){
    	$lop 	= new Admin_Model_Lops();
    	$lops 	= $lop->getAllLop();
    	$data 	= array();
    	foreach ($lops as $value) {
    		$data[$value['id']] = $value['tenLop'];
    	}
    	return $data;
    }
    

}

